﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IllustratedCsharp7_ch20_Linq
{
    class chapt20_6_6ExamplesOfUsingLambdaExpressionParameters
    {
        static void _Main()
        {
            int[] intArray = new int[] { 3, 4, 5, 6, 7, 9 };
            var countOdd = intArray.Count(x => x%2 ==1);
            Console.WriteLine($"Count of odd numbers:{countOdd}");

            //使用匿名方法来替代Lambda表达式
            Func<int,bool> myDel = delegate (int x)
            {
                return x % 2 == 1;
            };

            var countOdd1 = intArray.Count(myDel);
            Console.WriteLine($"Count of odd numbers:{countOdd1}");
        }        
    }
}
